home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / frasrc19.zip / PORT.H < prev    next >
C/C++ Source or Header  |  1995-01-28  |  7KB  |  239 lines

  1. /**************************************
  2. **
  3. ** PORT.H : Miscellaneous definitions for portability.    Please add
  4. ** to this file for any new machines/compilers you may have.
  5. **
  6. ** XFRACT file "SHARED.H" merged into PORT.H on 3/14/92 by --CWM--
  7. */
  8.  
  9. #ifndef PORT_H        /* If this is defined, this file has been    */
  10. #define PORT_H          /* included already in this module.             */
  11.  
  12. #define MSDOS 1
  13.  
  14. #ifdef XFRACT        /* XFRACT forces unix configuration! --CWM-- */
  15.  
  16.  /* CAE added ltoa, overwrite fix for HP-UX v9 26Jan95  */
  17. #ifdef _HPUX_SOURCE
  18. #define ltoa fr_ltoa
  19. #define overwrite fr_overwrite
  20. #endif
  21.  
  22. #ifdef MSDOS
  23. #undef MSDOS
  24. #endif
  25.  
  26. #ifdef __MSDOS__
  27. #undef __MSDOS__
  28. #endif
  29.  
  30. #ifndef unix
  31. #define unix
  32. #endif
  33.  
  34. #endif  /* XFRACT  */
  35.  
  36. #ifdef __TURBOC__
  37.    #define __cdecl cdecl
  38.  
  39. #ifndef __DOS_H
  40.       /*  dos.h is needed for MK_FP  */
  41.       #include <dos.h>
  42. #endif
  43. #endif
  44.  
  45. #ifdef MSDOS            /* Microsoft C 5.1 for OS/2 and MSDOS */
  46.                         /* NOTE: this is always true on DOS!  */
  47.                         /*       (MSDOS is defined above)  */
  48. #ifdef _MSC_VER         /* MSC assert does nothing under MSDOS */
  49. #ifdef assert
  50. #undef assert
  51. #define assert(X)
  52. #endif
  53. #endif
  54.  
  55.     typedef unsigned char  U8;
  56.     typedef signed char    S8;
  57.     typedef unsigned short U16;
  58.     typedef signed short   S16;
  59.     typedef unsigned long  U32;
  60.     typedef signed long    S32;
  61.     typedef unsigned char  BYTE;
  62.         typedef unsigned char  CHAR;
  63.         typedef void          *VOIDPTR;
  64.     typedef void far      *VOIDFARPTR;
  65.     typedef void const    *VOIDCONSTPTR;
  66.  
  67.     #define CONST          const
  68.     #define PRINTER        "/dev/prn"
  69.     #define LOBYTEFIRST    1
  70.     #define SLASHC         '\\'
  71.     #define SLASH          "\\"
  72.     #define SLASHSLASH     "\\\\"
  73.     #define SLASHDOT       "\\."
  74.     #define DOTSLASH       ".\\"
  75.     #define DOTDOTSLASH    "..\\"
  76.     #define READMODE    "rb"    /* Correct DOS text-mode        */
  77.     #define WRITEMODE    "wb"    /* file open "feature".         */
  78.  
  79.     #define write1(ptr,len,n,stream) fwrite(ptr,len,n,stream)
  80.     #define write2(ptr,len,n,stream) fwrite(ptr,len,n,stream)
  81.     #define rand15() rand()
  82.  
  83. #else            /* Have to nest because #elif is not portable */
  84. #ifdef AMIGA        /* Lattice C 3.02 for Amiga */
  85.     typedef UBYTE          U8;
  86.     typedef BYTE           S8;
  87.     typedef UWORD          U16;
  88.     typedef WORD           S16;
  89.     typedef unsigned int   U32;
  90.     typedef int            S32;
  91.     typedef UBYTE          BYTE;
  92.     typedef UBYTE          CHAR;
  93.  
  94.         typedef void          *VOIDPTR;
  95.     typedef void          *VOIDFARPTR;
  96.     typedef void          *VOIDCONSTPTR;
  97.  
  98.     #define CONST
  99.     #define PRINTER        "PRT:"
  100.     #define LOBYTEFIRST    0
  101.     #define SLASHC         '/'
  102.     #define SLASH          "/"
  103.     #define SLASHSLASH     "//"
  104.     #define SLASHDOT       "/."
  105.     #define DOTSLASH       "./"
  106.     #define DOTDOTSLASH    "../"
  107.     #define READMODE    "rb"
  108.     #define WRITEMODE    "wb"
  109.  
  110.     #define write1(ptr,len,n,stream) (fputc(*(ptr),stream),1)
  111.     #define write2(ptr,len,n,stream) (fputc((*(ptr))&255,stream),fputc((*(ptr))>>8,stream),1)
  112.     #define rand15() (rand()&0x7FFF)
  113.  
  114. #define BIG_ENDIAN
  115. #define USE_BIGNUM_C_CODE
  116.  
  117. #else
  118. #ifdef unix            /* Unix machine */
  119.     typedef unsigned char  U8;
  120.     typedef char           S8;
  121.     typedef unsigned short U16;
  122.     typedef short          S16;
  123.     typedef unsigned long  U32;
  124.     typedef long           S32;
  125.     typedef unsigned char  BYTE;
  126.         typedef char           CHAR;
  127. #define __cdecl
  128.  
  129. #ifdef BADVOID
  130.     typedef char          *VOIDPTR;
  131.     typedef char          *VOIDFARPTR;
  132.     typedef char          *VOIDCONSTPTR;
  133. #else
  134.     typedef void          *VOIDPTR;
  135.     typedef void          *VOIDFARPTR;
  136.     typedef void          *VOIDCONSTPTR;
  137. #endif
  138.  
  139.         /* Keep this defined for Unix, even on a little-endian machine */
  140. #define BIG_ENDIAN
  141.  
  142. #define USE_BIGNUM_C_CODE
  143.  
  144. #       define CONST
  145. #    define PRINTER        "/dev/lp"
  146. #    define SLASHC         '/'
  147. #    define SLASH          "/"
  148. #    define SLASHSLASH     "//"
  149. #    define SLASHDOT       "/."
  150. #    define DOTSLASH       "./"
  151. #    define DOTDOTSLASH    "../"
  152. #    define READMODE    "r"
  153. #    define WRITEMODE    "w"
  154.  
  155. #    define write1(ptr,len,n,stream) (fputc(*(ptr),stream),1)
  156. #    define write2(ptr,len,n,stream) (fputc((*(ptr))&255,stream),fputc((*(ptr))>>8,stream),1)
  157. #    define rand15() (rand()&0x7FFF)
  158.  
  159. #    include "unix.h"
  160.  
  161.  
  162. #endif
  163. #endif
  164. #endif
  165.  
  166. #ifdef LOBYTEFIRST
  167. #define GET16(c,i)        (i) = *((U16*)(&(c)))
  168. #else
  169. #define GET16(c,i)              (i) = (*(unsigned char *)&(c))+\
  170.                 ((*((unsigned char*)&(c)+1))<<8)
  171. #endif
  172.  
  173.  
  174. /* The following should work regardless of machine type */
  175. #include <float.h>
  176.  
  177. /* If you want to force the use of doubles, or                */
  178. /* if the compiler supports long doubles, but does not allow  */
  179. /*   scanf("%Lf", &longdoublevar);                            */
  180. /* to read in a long double, then uncomment this next line    */
  181. /* #undef LDBL_DIG           */
  182. /* #define USE_BIGNUM_C_CODE */  /* ASM code requires using long double */
  183.  
  184.  
  185. /* HP-UX support long doubles and allows them to be read in with  */
  186. /*   scanf(), but does not support the functions sinl, cosl, fabsl, etc.  */
  187. /* CAE added this 26Jan95 so it would compile (not sure how else to fix it)  */
  188. #ifdef _HPUX_SOURCE
  189. #undef LDBL_DIG
  190. #endif
  191.  
  192. #ifdef LDBL_DIG
  193. /* this is what we're hoping for */
  194. #define USE_LONG_DOUBLE
  195.         typedef long double LDBL;
  196. #else
  197. /* long double isn't supported */
  198. /* impliment LDBL as double */
  199.         typedef double          LDBL;
  200.  
  201. /* just in case */
  202. #undef LDBL_DIG        
  203. #undef LDBL_EPSILON
  204. #undef LDBL_MANT_DIG
  205. #undef LDBL_MAX        
  206. #undef LDBL_MAX_10_EXP 
  207. #undef LDBL_MAX_EXP    
  208. #undef LDBL_MIN        
  209. #undef LDBL_MIN_10_EXP 
  210. #undef LDBL_MIN_EXP    
  211. #undef LDBL_RADIX      
  212. #undef LDBL_ROUNDS     
  213.  
  214. #define LDBL_DIG        DBL_DIG        /* # of decimal digits of precision */
  215. #define LDBL_EPSILON    DBL_EPSILON    /* smallest such that 1.0+LDBL_EPSILON != 1.0 */
  216. #define LDBL_MANT_DIG   DBL_MANT_DIG   /* # of bits in mantissa */
  217. #define LDBL_MAX        DBL_MAX        /* max value */
  218. #define LDBL_MAX_10_EXP DBL_MAX_10_EXP /* max decimal exponent */
  219. #define LDBL_MAX_EXP    DBL_MAX_EXP    /* max binary exponent */
  220. #define LDBL_MIN        DBL_MIN        /* min positive value */
  221. #define LDBL_MIN_10_EXP DBL_MIN_10_EXP /* min decimal exponent */
  222. #define LDBL_MIN_EXP    DBL_MIN_EXP    /* min binary exponent */
  223. #define LDBL_RADIX      DBL_RADIX      /* exponent radix */
  224. #define LDBL_ROUNDS     DBL_ROUNDS     /* addition rounding: near */
  225.  
  226. #define sqrtl           sqrt
  227. #define logl            log
  228. #define log10l          log10
  229. #define atanl           atan
  230. #define fabsl           fabs
  231. #define sinl            sin
  232. #define cosl            cos
  233. #endif
  234.  
  235. /* 730 digits for DOS, only limits are memory and LDBL_MAX_10_EXP */
  236. #define MAX_BF_DIGITS   730
  237.  
  238. #endif  /* PORT_H */
  239.